package com.jandan.ui.server;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.gwtwidgets.server.spring.ServletUtils;

import com.jandan.logic.JWordzFacade;
import com.jandan.ui.client.service.WordLibService;
import com.jandan.ui.model.Word;
import com.jandan.ui.model.WordLib;
import com.jandan.web.front.UserSession;

public class WordLibServiceImpl implements WordLibService {
	private JWordzFacade jwordz;

	public void setJwordz(JWordzFacade jwordz) {
		this.jwordz = jwordz;
	}

	public List<WordLib> getWordLibList() {
		// TODO Auto-generated method stub
		return jwordz.getAllWordLibList();
	}

	public Word getWordByWordID(long wordID) {
		// TODO Auto-generated method stub
		return jwordz.getWordByWordID(wordID);
	}

	public void addStrangeWord(Word word) {
		// TODO Auto-generated method stub
		HttpSession session = ServletUtils.getRequest().getSession(true);
		UserSession userSession = (UserSession)session.getAttribute("userSession");
		if(userSession != null){
			 jwordz.insertStrangeWord(word,userSession.getAccount().getUserID());
		}
	}

	public Word getWordByWordEn(String wordEn) {
		// TODO Auto-generated method stub
		return jwordz.getWordByWordEn(wordEn);
	}
}
